package com.atguigu.gmall.item.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author: 李旭
 * @create: 2021-09-01 10:00
 *
 *   自定义线程池
 **/
@Configuration
public class ThreadPoolConfig {

    //将线程池放进SpringIOC容器中
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){

        return  new ThreadPoolExecutor(
                15,//核心线程数
                30,//最大线程数  5
                5,//存活时间：超出核心线程数的线程的存活时间
                TimeUnit.MINUTES,//单位
                new ArrayBlockingQueue(10) //队列
        );
    }
}
